package com.rmv.ums.condition;

import javax.servlet.http.HttpServletRequest;

import org.dom4j.Element;

public abstract class AbstractCondition implements Condition {

	// configuration
	protected String type;
	protected String value;
	protected String clazz;

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	public String getClassName() {
		return clazz;
	}

	public void setClassName(String className) {
		this.clazz = className;
	}

	// check method
	public abstract boolean check(HttpServletRequest request);

	public boolean configure(Element element) {
		// id
		this.type = element.attributeValue("type");

		// class
		this.clazz = element.attributeValue("class");

		// value
		this.value = element.getTextTrim();

		return true;
	}

	public String toString() {
		return "[condition:type=" + type + ",value=" + value + "]";
	}

}
